package com.kly.chatter.db.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.google.common.collect.Maps;
import com.kly.chatter.db.dao.ChatterImRewardDao;
import com.kly.chatter.db.entity.ChatterImRewardDBO;
import com.kly.chatter.db.entity.ChatterImRewardEntity;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

/**
 * User: linqu
 * Date: 2023-10-07
 * Time: 12:04:02.327
 */

@Repository
public class ChatterImRewardDaoImpl extends AbstractBaseMapper<ChatterImRewardEntity> implements ChatterImRewardDao {
    @Override
    public List<ChatterImRewardDBO> listChatterImRewardToday() {
        return this.getSqlSession().selectList(this.getStatement("listChatterImRewardToday"));
    }

    @Override
    public BigDecimal getImTotalReward(String chatterCode, Integer rewardDate) {
        final HashMap<String, Object> params = Maps.newHashMap();
        params.put("chatterCode", chatterCode);
        params.put("rewardDate", rewardDate);
        return (BigDecimal) this.getSqlSession().selectOne(this.getStatement("getImTotalReward"), params);
    }

    @Override
    public ChatterImRewardEntity getLastRecord(String chatterCode, String modelCode, String userCode, Integer rewardDate) {
        final HashMap<String, Object> params = Maps.newHashMap();
        params.put("chatterCode", chatterCode);
        params.put("modelCode", modelCode);
        params.put("userCode", userCode);
        params.put("rewardDate", rewardDate);
        return this.getSqlSession().selectOne(this.getStatement("getLastRecord"), params);
    }
}